<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Menutab extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		$this->load->helper(array('link'));
		$this->load->model(array('menutab_model', 'embassy_model', 'apply_model'));

	}
	
	
	
	function requirements(){// for form submit
		#get data.
		$country_name		=	$this->input->post('nationality');
		$country_name		=	preg_replace('/([\-])/is', ' ', $country_name);
		$check				=	$this->embassy_model->get_country_detail($country_name);
		$country			=	$this->apply_model->get_country();
		
		#assign data.
		$data['check']		=	$check;
		$data['country']	=	$country;
		
		$data['tpl_file']	=	"menutab/requirements";
		$this->load->view('layout/index', $data);
	}
	
	
	function check_requirements(){// for a list like embassy.
		
		$data['tpl_file']	=	"menutab/check_requirements";
		$this->load->view('fulllayout/index', $data);
	}
	
	
	function check_requirements_details($country_name	= ""){
		#get data.
		$country_name		=	preg_replace('/([\-])/is', ' ', $country_name);
		$check				=	$this->embassy_model->get_country_detail($country_name);
		$country			=	$this->apply_model->get_country();
		
		#assign data.
		$data['check']		=	$check;
		$data['country']	=	$country;
		
		$data['tpl_file']	=	"menutab/requirements";
		$this->load->view('layout/index', $data);
	}
	
	
	function how_to_apply(){
		#get faqs.
		$faqs				=	$this->menutab_model->get_faqs();
		$country			=	$this->apply_model->get_country();
	
		#assign data.
		$data['faqs']		=	$faqs;
		$data['country']	=	$country;
		
		$data['tpl_file']	=	"menutab/how_to_apply";
		$this->load->view('layout/index', $data);
	}
	
	
	function application_form(){
		#get info.
		$country			=	$this->apply_model->get_country();
	
		#assign data.
		$data['country']	=	$country;
		
		$data['tpl_file']	=	"menutab/application_form";
		$this->load->view('layout/index', $data);
	}
	
	
	function fees(){
		#get data from DB.
		$fees				=	$this->menutab_model->get_fees();
		$pax				=	explode('|',$fees[0]->pax);
		$type_visa			=	$this->apply_model->get_type_of_visa();
		$country			=	$this->apply_model->get_country();
		
		#assign data.
		$data['fees']		=	$fees;
		$data['pax']		=	$pax;
		$data['type_visa']	=	$type_visa;
		$data['country']	=	$country;
	
		$data['tpl_file']	=	"menutab/fees";
		$this->load->view('layout/index', $data);
	}
	
	
	
	function standard_fee(){
		#get data .
		$number_visa	=	$_POST['number_visa'];
		$type_visa		=	$_POST['type_visa'];
		$currency		=	$_POST['currency'];
		
		$prices			=	$this->apply_model->get_price($type_visa);
		$group_prices	=	explode('|', $prices['prices']);
		
		switch ($number_visa){
			case ($number_visa >=1 && $number_visa <= 2 ):
				$fee_per_each	=	$group_prices[0];
				break;
			case ($number_visa >=3 && $number_visa <= 5 ):
				$fee_per_each	=	$group_prices[1];
				break;
			case ($number_visa >= 6 && $number_visa <= 9 ):
				$fee_per_each	=	$group_prices[2];
				break;
			case ($number_visa >= 10):
				$fee_per_each	=	$group_prices[3];
				break;
		}
		
		if($currency == 'USD'){
			$standard_fee	=	$fee_per_each * $number_visa;
		}
		
		if($currency == 'EUR'){
			$standard_fee	=	$fee_per_each * $number_visa * 0.75554;
		}
		
		if($currency == 'GBP'){
			$standard_fee	=	$fee_per_each * $number_visa * 0.63009;
		}
		
		if($currency == 'AUD'){
			$standard_fee	=	$fee_per_each * $number_visa * 0.94531;
		}
		
		if($currency == 'CAD'){
			$standard_fee	=	$fee_per_each * $number_visa * 0.98787;
		}
		
		if($currency == 'NZD'){
			$standard_fee	=	($fee_per_each ) * $number_visa * 1.21277;
		}
		
		echo round($standard_fee, 2).' ('.$currency.')';
	}
	
	
	function express_fee(){
		#get data .
		$number_visa	=	$_POST['number_visa'];
		$type_visa		=	$_POST['type_visa'];
		$currency		=	$_POST['currency'];
		
		$prices			=	$this->apply_model->get_price($type_visa);
		$group_prices	=	explode('|', $prices['prices']);
		
		switch ($number_visa){
			case ($number_visa >=1 && $number_visa <= 2 ):
				$fee_per_each	=	$group_prices[0];
				break;
			case ($number_visa >=3 && $number_visa <= 5 ):
				$fee_per_each	=	$group_prices[1];
				break;
			case ($number_visa >= 6 && $number_visa <= 9 ):
				$fee_per_each	=	$group_prices[2];
				break;
			case ($number_visa >= 10):
				$fee_per_each	=	$group_prices[3];
				break;
		}
		
		if($currency == 'USD'){
			$express_fee	=	($fee_per_each + $prices['urgent_service']) * $number_visa;
		}
		
		if($currency == 'EUR'){
			$express_fee	=	($fee_per_each + $prices['urgent_service']) * $number_visa * 0.75554;
		}
		
		if($currency == 'GBP'){
			$express_fee	=	($fee_per_each + $prices['urgent_service']) * $number_visa * 0.63009;
		}
		
		if($currency == 'AUD'){
			$express_fee	=	($fee_per_each + $prices['urgent_service']) * $number_visa * 0.94531;
		}
		
		if($currency == 'CAD'){
			$express_fee	=	($fee_per_each + $prices['urgent_service']) * $number_visa * 0.98787;
		}
		
		if($currency == 'NZD'){
			$express_fee	=	($fee_per_each + $prices['urgent_service']) * $number_visa * 1.21277;
		}
		
		echo round($express_fee, 2).' ('.$currency.')';
	}
	
	
	
	function stamping_fee(){
		#get data .
		$type_visa		=	$_POST['type_visa'];
		$currency		=	$_POST['currency'];
		$prices			=	$this->apply_model->get_price($type_visa);
		if($currency == 'USD'){
			$stamping_fee	=	$prices['stamping_fee'];
		}
		if($currency == 'EUR'){
			$stamping_fee	=	$prices['stamping_fee'] * 0.75554;
		}
		if($currency == 'GBP'){
			$stamping_fee	=	$prices['stamping_fee'] * 0.63009;
		}
		if($currency == 'AUD'){
			$stamping_fee	=	$prices['stamping_fee']	* 0.94531;
		}
		if($currency == 'CAD'){
			$stamping_fee	=	$prices['stamping_fee'] * 0.98787;
		}
		if($currency == 'NZD'){
			$stamping_fee	=	$prices['stamping_fee'] * 1.21277;
		}
		
		echo round($stamping_fee, 2).' ('.$currency.')';
	}
	

}
/* End of file menutab.php */
/* Location: ./application/controllers/menutab.php */